package com.sqstudio.control
{
	import com.sqstudio.common.Sys;
	import com.sqstudio.event.CalendarEvent;
	import com.sqstudio.ui.LongBtn_RQJS;
	import com.sqstudio.view.CountPanel;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	/**
	 *日期计算控制器 
	 * @author Administrator
	 * 
	 */
	public class CountController
	{
		private var _countPanel:CountPanel;
		private var _countBtn:LongBtn_RQJS;
		public function CountController()
		{
			this._countPanel = new CountPanel();
			Sys.STAGE.addChild(this._countPanel);
			this._countPanel.x = 16;
			this._countPanel.y = 151;
			this._countPanel.visible = false;
			
			this._countBtn = new LongBtn_RQJS();
			Sys.STAGE.addChild(this._countBtn);
			this._countBtn.x = 320;
			this._countBtn.y = 407;
			
			this._countBtn.addEventListener(MouseEvent.CLICK,btnCkHandler);
			CalendarEvent.Dispatcher.addEventListener(CalendarEvent.COUNT_CHANGE,changeHandler);
		}
		
		private function changeHandler(e:CalendarEvent):void
		{
			if(int(e.data)==1){
				this._countPanel.visible = false;
			}else if(int(e.data)== -1){
				this._countPanel.visible = true;
			}
		}
		
		private function btnCkHandler(event:MouseEvent):void
		{
			CalendarEvent.Dispatcher.dispatchEvent(new CalendarEvent(CalendarEvent.COUNT_CHANGE,-1));
			
		}
	}
}